FROM node:22-alpine AS build-stage
WORKDIR /app
ENV NODE_OPTIONS=--max_old_space_size=8192
COPY package.json pnpm-lock.yaml* ./
RUN npm config set registry https://registry.npmmirror.com
RUN npm install pnpm -g && \
    pnpm config set registry https://registry.npmmirror.com && \
    pnpm store prune && \
    pnpm install
RUN echo "pnpm install successful"
COPY . ./
RUN pnpm build-only

# Stage 2: production stage
FROM docker.m.daocloud.io/nginx:latest AS production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
